using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HeresyManager.Skills.Cipherses
{
    [Serializable]
    public class CiphersSecretSociety : Ciphers
    {
        public String Society { get; private set; }

        public CiphersSecretSociety(SkillLevel level)
            : base(level)
        {
        }

        public CiphersSecretSociety(SkillLevel level, String society)
            : this(level)
        {
            Society = society;
        }


        internal override IEnumerator<Comunication.Comunicator> Accire(Character character)
        {
            if (String.IsNullOrWhiteSpace(Society))
            {
                var com = new Comunication.EnterStringComunicator("Society");
                while (String.IsNullOrWhiteSpace(com.Answer))
                    yield return com;
                Society = com.Answer;
            }
            var en = base.Accire(character);
            while (en.MoveNext())
                yield return en.Current;
        }

        public override string Name
        {
            get
            {
                return "Ciphers (Secret Society-" + this.Society + ")";
            }
        }

        // override object.Equals
        public override bool Equals(object obj)
        {
            return base.Equals(obj) && this.Name.Equals((obj as CiphersSecretSociety).Name);
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return base.GetHashCode() * 31 + Name.GetHashCode();
        }
    }
}
